package com.bsj.power.system.web;

import com.bsj.power.common.config.global.JsonResult;
import com.bsj.power.common.def.dto.open.OpenV1DTO;
import com.bsj.power.system.config.annotation.OpenV1;
import com.bsj.power.system.service.OpenApiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author yinhao
 * @version 1.0
 * @description 开放接口
 * @date 2024/7/10
 */
@RestController
@RequestMapping(path = "", produces = "application/json")
public class OpenApiController {

    @Autowired
    private OpenApiService openApiService;

    /**
     * 第三方登录授权
     *
     * @param request
     * @param dto
     * @return
     */
    @PostMapping("/v1/open/api/loginUrl")
    @OpenV1
    public JsonResult<String> loginUrl(HttpServletRequest request, @RequestBody OpenV1DTO dto) {
        return JsonResult.success(openApiService.loginUrl(request, dto));
    }
}
